const lifecycles = {
  beforeLoad: (appWindow) => console.log(`${appWindow.__WUJIE.id} beforeLoad 生命周期`),
  beforeMount: (appWindow) => console.log(`${appWindow.__WUJIE.id} beforeMount 生命周期`),
  afterMount: (appWindow) => console.log(`${appWindow.__WUJIE.id} afterMount 生命周期`),
  beforeUnmount: (appWindow) => console.log(`${appWindow.__WUJIE.id} beforeUnmount 生命周期`),
  afterUnmount: (appWindow) => console.log(`${appWindow.__WUJIE.id} afterUnmount 生命周期`),
  activated: (appWindow) => console.log(`${appWindow.__WUJIE.id} activated 生命周期`),
  deactivated: (appWindow) => console.log(`${appWindow.__WUJIE.id} deactivated 生命周期`),
  loadError: (url, e) => console.log(`${url} 加载失败`, e)
}

function fetch(url, options) {
  return window.fetch(url, { ...options, credentials: 'omit' })
}

const map = {
  '//localhost:4424/': 'http://localhost:4424'
  // '//localhost:8081/': '//wujie-micro.github.io/demo-vue2/',
}
function hostMap(host) {
  return map[host]
}

const props = {
  jump: (name) => {
    router.push({ name })
  }
}
const degrade =
  window.localStorage.getItem('degrade') === 'true' ||
  !window.Proxy ||
  !window.CustomElementRegistry

const isProduction = process.env.NODE_ENV === 'production'
const attrs = isProduction ? { src: hostMap('//localhost:4424/') } : {}

export { fetch, hostMap, lifecycles, degrade, props, attrs }

